package com.qiankan.qmsj.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.widget.RelativeLayout;

import com.qiankan.qmsj.AppPrefs;
import com.qiankan.qmsj.BuildConfig;
import com.qiankan.qmsj.MainActivity;
import com.qiankan.qmsj.R;

import butterknife.BindView;

public class WelcomeActivity extends BaseActivity {
    private static final int sleepTime = 2000;
    @BindView(R.id.splash_root)
    RelativeLayout rootLayout;

    @Override
    public int getContentViewId() {
        return R.layout.activity_welcome;
    }

    @Override
    protected void initAllMembersView(Bundle savedInstanceState) {
        AlphaAnimation animation = new AlphaAnimation(0.3f, 1.0f);
        animation.setDuration(1500);
        rootLayout.startAnimation(animation);
    }

    @Override
    protected void onStart() {
        super.onStart();
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(sleepTime);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
                /*String lastVersionCode = AppPrefs.getInstance(WelcomeActivity.this).getVersionCode();
                String currentVersionCode = BuildConfig.VERSION_CODE + "";
                if (currentVersionCode.compareTo(lastVersionCode) > 0) {
                    AppPrefs.getInstance(WelcomeActivity.this).saveVersionCode();
                    startActivity(new Intent(WelcomeActivity.this, SplashActivity.class));
                } else {
                    startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
                }*/
                finish();
            }
        }).start();
    }
}
